﻿<div ms-controller="tempview">
    <div class="sui-form form-inline" style="padding-top:5px;">
        <select class="input-large input-xfat" ms-change="GetLIST()" ms-duplex="InfoType">
            <option value="">请选择分类</option>
            <option ms-repeat-el="CatData1" ms-attr-value="el.ID">{{el.TypeName}}</option>
        </select>
        <input type="text" ms-duplex="searchkey" placeholder="关键字搜索" class="input-large input-xfat" />
        <a class="sui-btn btn-large btn-primary" style="margin-left:10px;" ms-click="GetLIST()">查询</a>
        <a style="margin-left:10px;" class="sui-btn btn-large btn-success" ms-click="ADD('')" ms-if="top.model.HasAuth('ADD')">添加</a>
    </div>


    <table class="sui-table table-primary table-zebra">
        <thead>
            <tr>
                <th>会员类型</th>
                <th>会员ID</th>
                <th>手机号</th>
                <th>用户昵称</th>
                <th>真实姓名</th>
                <th>积分</th>
                <th>状态</th>
                <th style="width:150px">注册时间</th>
                <th style="width:120px">操作</th>
            </tr>
        </thead>
        <tbody>
            <tr ms-repeat-el="ListData">
                <td>{{ShowType(el.UserType)}}</td>
                <td>{{el.ID}}</td>
                <td>{{el.Telephone}}</td>
                <td>{{el.NickName}}</td>
                <td>{{el.TrueName}}</td>
                <td>{{el.Points}}</td>
                <td><span class="sui-text-success" ms-if="el.Status==0">正常</span><span class="sui-text-danger"  ms-if="el.Status==9">禁用</span></td>
                <td>{{el.CRTime|date('yyyy-MM-dd HH:mm:ss')}}</td>
                <td>
                    <a href="javascript:void(0);" class="sui-btn btn-bordered btn-warning" ms-click="Enable(el)" ms-if="top.model.HasAuth('EDIT')">{{el.Status==0?'禁用':'启用'}}</a>
                    <a href="javascript:void(0);" class="sui-btn btn-bordered btn-success" ms-click="ADD(el)">编辑</a>
                </td>
            </tr>
        </tbody>
    </table>

</div>
<script type="text/javascript">
    var tempmodel = avalon.define({
        $id: "tempview",
        SHOW: function (el) {
            top.ComFunJS.winShowForm("/admin/list/signlist.html?rid=" + el.ID, "查看");
        },
        CatData1: "",
        Init: function () {
            $.getJSON("/adapi/base/catelist/4", function (r) {
                tempmodel.CatData1 = r.result;
            })
            tempmodel.GetLIST();
        },
        Type1:"",
        GetLIST: function () {
            model.page.pageindex = 1;
            model.ListData.clear();
            $.getJSON("/adapi/jd/list", { pageindex: model.page.pageindex, pagesize: model.page.pagesize, key: model.searchkey, usertype: tempmodel.usertype }, function (r) {
                if (r.error == "") {
                    model.ListData = r.result;
                    model.total = r.total;

                    $("#pageDiv").pagination({  //分页容器
                        styleClass: ['sui-pagination'],  //分页样式
                        //showCtrl: false,
                        displayPage: 6,
                        itemsCount: r.total,
                        pageSize: model.page.pagesize,
                        onSelect: function (num) {
                            model.page.pageindex = num;
                            $.getJSON("/adapi/jd/list", { pageindex: model.page.pageindex, pagesize: model.page.pagesize, key: model.searchkey, usertype: tempmodel.usertype }, function (r) {
                                model.ListData.clear();
                                model.ListData = r.result;
                            })
                        }
                    })

                    $('#pageDiv').pagination('updateItemsCount', r.total, 1);
                }
            })
        },
        Enable:function(el){
            $.getJSON("/adapi/jd/enable/" + el.ID, function (r) {
                if (r.error == "") {
                    el.Status = el.Status == 0 ? 9 : 0;
                }
            });
        }
    });

</script>
